package com.onairm.baselibrary.mvp.activity;

import android.os.Bundle;

import com.onairm.baselibrary.mvp.base.MvpCallback;
import com.onairm.baselibrary.mvp.base.MvpPresenter;
import com.onairm.baselibrary.mvp.base.MvpView;
import com.onairm.baselibrary.mvp.base.ProxyMvpCallback;

/**
 * Created by bqy on 2018/3/27.
 *
 * 代理模式：第一重代理-》代理Activity生命周期
 * 实现生命周期方法(很多功能，例如：绑定和解绑、数据缓存、View状态缓存等等..一些逻辑)
 */

public class ActivityMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<V>> implements ActivityMvpDelegate<V, P> {


    private ProxyMvpCallback<V, P> proxyMvpCallback;

    public ActivityMvpDelegateImpl(MvpCallback<V, P> mvpCallback) {
        this.proxyMvpCallback = new ProxyMvpCallback<V, P>(mvpCallback);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        proxyMvpCallback.createPresenter();
        proxyMvpCallback.attachView();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onRestart() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onDestroy() {
        proxyMvpCallback.detachView();
    }
}
